<?php
//获取当前user信息
$userCooker = new BAUserCooker();
$userInfo = $userCooker->getUserInfo();
//var_dump($userInfo);
$familyNameAttr = '';
$surNameAttr = '';
if($userInfo->getItem('familyName') != NULL)
    $familyNameAttr = $userInfo->getItem('familyName')->getValue();
if($userInfo->getItem('surName') != NULL)
    $surNameAttr = $userInfo->getItem('surName')->getValue();
?>
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl.'/css/BWeMember/wei_webapp_new.css'?>">
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl.'/css/BWeMember/wei_dialog.css'?>">
<link rel="stylesheet" type="text/css" href="<?php echo Yii::app()->request->baseUrl.'/css/BWeMember/common.css'?>">

<!-- ajax加载页面时弹出加载旋转gif图 -->
<style>
    #ajax-loaderdiv {position: fixed;top: 0;left: 0;width: 100%;height: 100%;z-index: 35000;background-color: rgba(0, 0, 0, 0.3);display: none;}
    .ajax-loader {position: absolute;left: 50%;top: 50%;margin-left: -16px;margin-top: -16px;display: block;}
</style>
    <style type="text/css">
/*	.main{width: 350px;height: 100px;background-color: white;padding-top: 8px;}
	.tu{width:96px;height: 74px;float: left;margin-left: 8px;}
	.wen{width: 200px;float: left;margin-left: 10px;}
        .wen p {line-height: 28px;}*/
	#imgGo {overflow: hidden; position: relative;  padding: 0;margin: 0 auto;}
	#imgGo ul {overflow: hidden; position: absolute; top: 0; left: 0; margin: 0; padding: 0;}
	#imgGo ul li {overflow: hidden; float: left; margin: 0; padding: 0;}
	#imgIndex {overflow: hidden; position: absolute; bottom: 0; margin: 0; padding-right:50%; width: 100%; height: 12%; text-align: center;}
	#imgIndex span {display: inline-block; width: 10px; height: 10px; margin-right: 3%; border-radius: 100%; background-color: #BDBDBD;cursor: pointer; opacity: 0.4;}

	.shadow{height: 60px;width: 290px;background-color: black;border-radius: 5px;opacity:0.45;}
	.img{position:absolute;top: 180px;left: 50%;margin-left:-146px;}
  	img.s{border:0;height: 100px;width:100%;}
  	img.l{border:0;height: 60px;width:60px;display:inline-block;margin-bottom:10px;}
    </style>
<div id="ajax-loaderdiv" style="display: none;">
    <img src="<?php echo Yii::app()->request->baseUrl.'/images/ajax-loader.gif'?>" class="ajax-loader">
</div>


<div id="page_card" class="div-body">

    <div id="mappContainer">
        <div class="inner root" style="height: 519px;">
<!--            <div class="card" style="background:url(<?php echo Yii::app()->request->baseUrl.'/images/BWeMember/wei_webapp_new/card_bk_1.png'?>) no-repeat 0 0;-webkit-background-size:267px 159px;background-size:267px 159px;" data-card-type="0">
                <img src="<?php echo Yii::app()->request->baseUrl.'/images/BWeMember/weixin_shop_logo/2543529110_card_170_170.png'?>" class="logo">
                <h1></h1>
                <strong class="pdo verify">
                    <span style="color:#92714e;text-shadow:0 1px #f1e7dc;"><em style="color:#92714e;text-shadow:0 1px #f1e7dc;">会员名</em><?php echo $familyNameAttr.$surNameAttr;?></span>
                </strong>
            </div>-->
        <?php
        if($billView){ ?>
    <div  id="imgGo">
        <ul id="testUl">
            <?php
            $cardCooker = new BAMemberCardCooker();
            $userCooker = new BAUserCooker();
            $permitCooker = new BAPermitCooker();
            $memberPointCooker = new BAMemberPointCooker();
            $memberPoint = '';
            foreach ($billView as $id => $list) {
                $userInfoId = $list->getItem('userInfoId')->getValue();
                $cardId = $list->getItem('cardId')->getValue();
                $cardTypeId = $list->getItem('cardTypeId')->getValue();
                $permitId = $list->getItem('permitId')->getValue();
                $cardType = $cardCooker->getCardType($cardTypeId);
                $userInfo = $userCooker->getUserInfo($userInfoId);
                $oPermit = $permitCooker->getPermit($permitId);
                //$card = $cardCooker->getCard($cardId);
                $cardTypeAlias = $cardType->getValue();
                $after10year = strtotime("+10 years");
                $expire = $oPermit->getItem('expireTime')->getValue();
                if ($expire > $after10year) {
                    $expireTime = '10年后';
                } else {
                    $expireTime = date('Y/m/d:H', $expire);
                }

                $name = '---';
                if ($userInfo != NULL) {
                    if ($userInfo->getItem('familyName') != NULL) {
                        $name = $userInfo->getItem('familyName')->getValue();
                    }
                    if ($userInfo->getItem('surName') != NULL) {
                        $surName = $userInfo->getItem('surName')->getValue();
                        if ($name == '---')
                            $name = $surName;
                        else {
                            $name.=$surName;
                        }
                    }
                }
                $preCardType = $cardCooker->getPreCardTypeFromCardType($cardType);
                if ($preCardType == 'memberPointCard') {
                    $memberPointCooker = new BAMemberPointCooker();
                    //get memberPoint Type
                    $memberPointTypeId = $cardCooker->getCardTypeAttribute('memberPointType', $cardType);

                    $memberPointType = $memberPointCooker->getMemberPointType($memberPointTypeId);

                    //get memberPointAccount
                    $mpAccount = $memberPointCooker->getMemberPointAccountByUser($memberPointType);

                    if ($mpAccount != NULL) {
                        $accountData = $mpAccount->getItemsInArray();
                        $memberPoint = $accountData['memberPoint'];
                    }
                }
                ?>
            
                <li>
                    <div class="card" style="background:url(<?php echo Yii::app()->request->baseUrl.'/images/BWeMember/wei_webapp_new/card_bk_1.png'?>) no-repeat 0 0;-webkit-background-size:267px 159px;background-size:267px 159px;" data-card-type="0">
                        <img src="<?php echo Yii::app()->request->baseUrl.'/images/BWeMember/weixin_shop_logo/2543529110_card_170_170.png'?>" class="logo">
                        <strong class="pdo verify">
                            <span style="color:#92714e;text-shadow:0 1px #f1e7dc;float: left;margin-left: 10px;"><em style="color:#92714e;text-shadow:0 1px #f1e7dc;">会员卡类型</em><?php echo $cardTypeAlias;?></span>
                            <span style="color:#92714e;text-shadow:0 1px #f1e7dc;float: left;margin-left: 20px;"><em style="color:#92714e;text-shadow:0 1px #f1e7dc;">我的积分</em><?php echo $memberPoint;?></span>
                            <span style="color:#92714e;text-shadow:0 1px #f1e7dc;"><em style="color:#92714e;text-shadow:0 1px #f1e7dc;">卡号</em><?php echo $cardId;?></span>
                        </strong>
                    </div>
                </li>
            <?php } ?>
            </ul>
            <div id="imgIndex"></div>
       </div>
        <?php  }
         if(!$billView){
             ?>
            <div class="card" style="background:url(<?php echo Yii::app()->request->baseUrl.'/images/BWeMember/wei_webapp_new/card_bk_1.png'?>) no-repeat 0 0;-webkit-background-size:267px 159px;background-size:267px 159px;" data-card-type="0">
                <img src="<?php echo Yii::app()->request->baseUrl.'/images/BWeMember/weixin_shop_logo/2543529110_card_170_170.png'?>" class="logo">
                <h1></h1>
                <strong class="pdo verify">
                    <span style="color:#92714e;text-shadow:0 1px #f1e7dc;"><em style="color:#92714e;text-shadow:0 1px #f1e7dc;">会员名</em><?php echo $familyNameAttr.$surNameAttr;?></span>
                </strong>
            </div>
        <?php }
         ?>
       <p><span>
           <?php
           if($billView){
               echo '我的会员卡';
           }  else {
               echo '您暂时没有可以用的会员卡，请先领取会员卡,您可以通过以下链接领取会员卡';
           }
       ?></span></p>
       <?php
       if(!$billView){
            echo $control->getAjaxLink('领取会员卡', array(
                'cooker' => 'BAMemberCard@showUserCardApplyList',
               'htmlOptions' => array('class' => 'btn btn-warning')
            ));
       }
       ?>
	<script src="<?php echo Yii::app()->request->baseUrl.'/js/mobile/imgGo_memberCard.js';?>" type="text/javascript"></script>
                <?php
                echo $control->getAjaxLink('返回', array(
                    'cooker' => 'BAMemberCard@showUserCardHome',
                    'htmlOptions' => array('class' => 'btn btn-primary','style'=>'width: 100%;')
                ));
                ?>
        </div>
    </div>

    <div id="mCopyright">
        <div class="mcrInn">
            <h1>比邻平台</h1>
        </div>
    </div>

</div>
